#-*- coding:utf-8 -*-

import sys
from common.config import *
import common.opmysql
import allure
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
import websocket

# 游戏状态码
# NOT_START(0, "游戏未开始 "),# STARTED(1, "已开始"),# PROGRESS(2, "游戏进行中"),# OVER(3, "游戏已结束")
# 用户状态码
# PERSON_DIE("0", "蛇不在大屏端（死亡）"),# PERSON_ALIVE("1", "蛇在设备端（活着）"),# NEW_PERSON("2", "新加入用户"),# PERSON_FULL("3", "人数已满"),
# NOT_ADD("4", "活动无效，不允许加入"),# WAIT("5","游戏等待"),# PARTICIPATE_FAIL("6","参与失败")
# def websocket(env, data,ws):
#     ws.send(json.dumps(data))
#     print (data)
#     result = json.loads(ws.recv())
#     print("返回", result)  # 查看返回
#     # ws.close()
#     return result

class TestActivity():
    @allure.step('活动详细信息')
    #参数：活动id
    def getActivityInfo(self,env,activityId):
        zhongtai_url = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json;charset=UTF-8","token":token}
        url = zhongtai_url + "game-manager/v1/activity/getActivityInfo"
        data = {"activityId":activityId}
        print (url,data)
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('活动分页查询')
    #参数：活动id
    def getActivityList(self,env,name):
        zhongtai_url = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json;charset=UTF-8","token":token}
        url = zhongtai_url + "game-manager/v1/activity/getActivityList"
        data = {"name":name}
        print (url,data)
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('活动基本信息')
    def baseInfo(self,env,activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/baseInfo/get"
        data = {"activityId":activityId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('活动启用/禁用')
    #参数：活动id
    def enableOrDisableGame(self,env,activityId,status):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-manager/v1/activity/enableOrDisableGame"
        data = {"activityId":activityId,"status":status}
        # print("活动启用",data)
        token=buslogin(env)
        r=requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('活动参与情况')
    # 参数：活动id
    def participation(self,env,activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/participation/get"
        data = {"activityId":activityId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('活动参与情况')
    # 参数：活动id
    def baseInfo(self,env,activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/baseInfo/get"
        data = {"activityId":activityId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('活动奖品信息')
    # 参数：活动id,开奖类型：0 随机，1 排名，2分值，3 参与
    def prize(self,env,activityId,discoverType):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/prize/get"
        data = {"activityId":activityId,"discoverType":discoverType}
        r=requests.post(url,json=data,headers=headers)
        print (url)
        return r

    @allure.step('活动排行接口')
    # 参数：activityId:活动id,rankType:排行类型（1：天排行，2：周排行，3：上周排行，4：月排行，5：上月排行，6：总排行）
    # rankNature:排行值类型（1:最高分排行，2：总分排行），rankSort:排行排序（asc，desc）
    #非必参数 pageSize:获取前多少排名，默认前10名，openId:当前用户openId，传了则会显示当前用户排名，showWinningRecord:Boolean	是否展示奖品信息
    def rank(self,env,activityId,rankType,rankNature,rankSort):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/ranking/list"
        data = {"activityId":activityId,"rankType":rankType,"rankNature":rankNature,"rankSort":rankSort}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('抽奖状态查询')
    def lottyStatus(self,env,activityId,playRecordId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/lottyStatus/get"
        data = {"activityId":activityId,"playRecordId":playRecordId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('发排行奖接口')
    # 参数：activityId:活动id,rankType:排行类型（1：天排行，2：周排行，3：上周排行，4：月排行，5：上月排行，6：总排行）
    # rankNature:排行值类型（1:最高分排行，2：总分排行），rankSort:排行排序（asc，desc）
    #非必参数 pageSize:获取前多少排名，默认前10名，openId:当前用户openId，传了则会显示当前用户排名，showWinningRecord:Boolean	是否展示奖品信息
    def rankprize(self,env,activityId,rankType,rankNature,rankSort):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/lotty/rankLotty"
        data = {"activityId":activityId,"pageSize":999,"rankType":rankType,"rankNature":rankNature,"rankSort":rankSort}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('屏端查排行奖接口')
    # 排行类型type(1实时排行,2历史排行)
    def rankByType(self,env,activityId,type):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/rank/rankByType"
        data = {"activityId":activityId,"type":type}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('获取活动二维码')
    def getqrcode(self,env,activityId):
        headers = {"Content-Type": "application/json"}
        dayu_url=getconf(env,"dayu_url")
        url = dayu_url + "game-portal/v1/activity/qrcode/get"
        data = {"activityId": activityId,"reusable":"true","isSession":"true"}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('检查活动二维码是否被扫')
    def checkScan(self,env,activityId,qrCodeKey):
        headers = {"Content-Type": "application/json"}
        dayu_url=getconf(env,"dayu_url")
        url = dayu_url + "game-portal/v1/activity/qrcode/checkScan"
        data = {"activityId": activityId,"qrCodeKey": qrCodeKey}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('关闭活动二维码')
    def closeqrcode(self,env,activityId,qrCodeKey):
        headers = {"Content-Type": "application/json"}
        dayu_url=getconf(env,"dayu_url")
        url = dayu_url + "game-portal/v1/activity/qrcode/close"
        data = {"activityId": activityId,"qrCodeKey": qrCodeKey}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('二维码扫码通知')
    def notice(self,env,openId,channelCode,qrcodeId,activityId):
        headers = {"Content-Type": "application/json"}
        dayu_url=getconf(env,"dayu_url")
        url = dayu_url + "game-portal/v1/activity/qrcode/notice"
        data = {"openId": openId,"channelCode": channelCode,"qrcodeId": qrcodeId,"activityId":activityId,"subscribe":"true","nickName":"昵称","subscribeCount":2,"headImgUrl":"http://thirdwx.qlogo.cn/2"}
        r=requests.post(url,json=data,headers=headers)
        # print (data)
        return r

    @allure.step('更新活动')
    def updateactivity(self,env,data):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type":"application/json","Token":token}
        apiurl="game-manager/v1/activity/update"
        url = zhongtaiurl + apiurl
        r=requests.post(url,json=data,headers=headers)
        # print ("giweufwf",data)
        # value=[1,"Test_11","updateactivity","POST",zhongtaiurl,apiurl,str(headers),str(data)]
        # value=["updateactivity","POST",zhongtaiurl,apiurl,json.dumps(headers),json.dumps(data,ensure_ascii=False)]
        # print ("value",value,"111111111111111")
        # writedata(value)
        return r

    @allure.step('新更新活动接口')
    def updateactivitynew(self,env,data):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type":"application/json","Token":token}
        apiurl="game-manager/v2/activity/update"
        url = zhongtaiurl + apiurl
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('天玑2.0更新活动接口')
    def updateactivity2(self,env,data):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type":"application/json","Token":token}
        apiurl="game-manager/v3/activity/update"
        url = zhongtaiurl + apiurl
        r=requests.post(url,json=data,headers=headers)
        return r


    @allure.step('总奖池设置接口')
    def savePrizePool(self,env,data):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type":"application/json","Token":token}
        apiurl="game-manager/v1/activity/session/savePrizePool"
        url = zhongtaiurl + apiurl
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('总奖池查询接口')
    def findPrizePool(self,env,activityId):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type":"application/json","Token":token}
        apiurl="game-manager/v1/activity/session/findPrizePool"
        url = zhongtaiurl + apiurl
        r=requests.post(url,json={"activityId": activityId},headers=headers)
        return r

    @allure.step('复制活动')
    def copyactivity(self,env,activityId):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        token=buslogin(env)
        url = zhongtaiurl + "game-manager/v1/activity/copy"
        r=requests.post(url,json={"activityId":activityId},headers=headers,params={"Token":token})
        return r

    @allure.step('活动白名单上传')
    def uploadFile(self,env,activityId):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        filepath=data_path+"pwl.xlsx"
        m=MultipartEncoder(fields={"file": ("pwl.xlsx",open(filepath, "rb"))})
        headers = {'Content-Type': m.content_type}
        url = zhongtaiurl + "game-manager/v1/activity/participateWhitelist/uploadFile"
        r=requests.post(url,data=m,headers=headers,params={"Token":token,"activityId":activityId})
        return r

    @allure.step('上传文件')
    def taskuploadfile(self,env,taskFunctionCode):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        url = zhongtaiurl + "platform-datapump-server/v1/task/uploadfile"

        if taskFunctionCode=='import_activity_participate_white':#手机号
            filepath = data_path + "phone_Tpl.xlsx"
            m = MultipartEncoder(fields={"taskFunctionCode":taskFunctionCode,"file": (filepath, open(filepath, "rb"))})
            headers = {'Content-Type': m.content_type, "Token": token}
        if taskFunctionCode=='import_activity_participate_user_id_white':#userid
            filepath = data_path + "UserId_Tpl.xlsx"
            m = MultipartEncoder(fields={"taskFunctionCode": taskFunctionCode,"file": (filepath, open(filepath, "rb"))})
            headers = {'Content-Type': m.content_type, "Token": token}
        if taskFunctionCode=='import_activity_question':#userid
            filepath = data_path + "question_tpl.xlsx"
            m = MultipartEncoder(fields={"taskFunctionCode": taskFunctionCode,"file": (filepath, open(filepath, "rb"))})
            headers = {'Content-Type': m.content_type, "Token": token}
        r = requests.post(url, headers=headers, data=m)
        return r

    @allure.step('提交任务')
    def tasksubmit(self,env,activityId,fileId,taskFunctionCode):
        zhongtaiurl = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Token":token,'Content-Type': "application/json"}
        url = zhongtaiurl + "platform-datapump-server/v1/task/submit"
        if taskFunctionCode=="import_activity_question":
            data = {"bizContent": {"activityId": activityId,"answerNum": 3}, "fileId": fileId, "taskFunctionCode": taskFunctionCode}
        else:
            data = {"bizContent": {"activityId": activityId}, "fileId": fileId, "taskFunctionCode": taskFunctionCode}
        r=requests.post(url,headers=headers,json=data)
        # print (data)
        return r

    @allure.step('活动中奖名单列表(分页)')
    # 参数:discoverStatus，开奖状态：1：开奖中（只开某一个奖品结束），2:本场次所有的奖品开奖结束
    def listlottyName (self,env,activityId,sessionId,discoverStatus):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"sessionId":sessionId,"discoverStatus":discoverStatus}
        url = zhongtaiurl + "game-portal/v1/activity/lottyName/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('打卡接口')
    def qrCodeInfosave (self,env,activityId,secretStr,writeOffOpenid):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"secretStr":secretStr,"writeOffOpenid":writeOffOpenid}
        url = zhongtaiurl + "game-portal/v1/activity/clockIn/qrCodeInfo/save"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('分页查询打卡记录')
    def clockInuserlist (self,env,activityId,recordId):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"recordId":recordId,"size":10,"current":1}
        url = zhongtaiurl + "game-portal/v1/activity/clockIn/user/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('分页查询核销的打卡记录')
    def clockInlist (self,env,activityId,writeOffDate,writeOffOpenid):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"writeOffDate":writeOffDate,"writeOffOpenid":writeOffOpenid,"size":10,"current":1}
        url = zhongtaiurl + "game-portal/v1/activity/clockIn/list"
        r=requests.post(url,json=data,headers=headers,)
        print (data)
        return r

    @allure.step('更新会员信息')
    def memberInfoupdate (self,env,activityId,appid,id,cardCode,realname):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"appid":appid,"id":id,"cardCode":cardCode,"realname":realname}
        url = zhongtaiurl + "game-portal/v1/user/memberInfo/update"
        r=requests.post(url,json=data,headers=headers,)
        print (data)
        return r

    @allure.step('活动店铺查询')
    def shoplist (self,env,activityId,openId,userId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"openId":openId,"userId":userId}
        url = dayu_url + "game-portal/v1/activity/shop/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('活动店铺奖品展示')
    def shopprize (self,env,activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId}
        url = dayu_url + "game-portal/v1/activity/shop/prize/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('店铺二维码查询')
    def qrCodeInfoget (self,env,activityId,recordId,shopId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"recordId":recordId,"shopId":shopId}
        url = dayu_url + "game-portal/v1/activity/clockIn/qrCodeInfo/get"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('查询二维码状态')
    def qrCodeInfoquery (self,env,activityId,recordId,shopId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"recordId":recordId,"shopId":shopId}
        url = dayu_url + "game-portal/v1/activity/clockIn/qrCodeInfo/query"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('成就列表')
    def achievementlist(self,env,activityId,openId,userId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"openId":openId,"userId":userId}
        # print ("查成就列表参数",data)
        url = dayu_url + "game-portal/v1/activity/achievement/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('获取用户参与记录id列表')
    def getIdList(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"openId":openId}
        url = dayu_url + "game-portal/v1/user/participation/getIdList"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('成就领奖')
    def achievementlottery(self,env,activityId,achievementId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId,"achievementId":achievementId,"openId":openId}
        url = dayu_url + "game-portal/v1/user/achievement/lottery"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('成就奖品展示')
    def achievementprizelist(self,env,activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        data = {"activityId": activityId}
        url = dayu_url + "game-portal/v1/activity/achievement/prize/list"
        r=requests.post(url,json=data,headers=headers,)
        return r

    @allure.step('高级玩法配置保存')
    def saveHighPlay(self,env,data):
        zhongtaiurl = getconf(env, "zhongtai_url")
        headers = {"Content-Type": "application/json"}
        token=buslogin(env)
        url = zhongtaiurl + "game-manager/v1/activity/saveHighPlay"
        r=requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('活动题库抽题')
    # questionNum:获取题的数量,活动id
    def questionList(self,env,activityId,questionNum):
        dayu_url = getconf(env,"dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/question/list"
        data = {"activityId":activityId,"questionNum":questionNum}
        r = requests.post(url,json=data,headers=headers)
        return r


    @allure.step('三方任务增加次数')
    def third_addTime(self, env, activityId,openId,accountId,serialNo,remarks,addTimes,channel):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/activity/external/task/addTime"
        data = {"activityId": activityId,"openId": openId,"accountId": accountId,"serialNo": serialNo,"remarks": remarks,"addTimes": addTimes,"channel": channel}
        r=requests.post(url,json=data,headers=headers)
        return r

class TestSession():
    @allure.step('获取当前有效场次')
    def getEffective(self, env, activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/session/getEffective"
        data = {"activityId":activityId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('获取场次信息')
    def sessioninfo(self, env, activityId,sessionId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/session/info"
        data = {"activityId":activityId,"sessionId":sessionId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('场次开奖流程（手动开奖）')
    # 参数 prizeId（奖品id，action=2 或 3，必传）
    # 参数 awardPrizeCount（发奖份数，全部发奖时，传剩余库存，action=2，必传）
    def sessionprocess(self, env, activityId,sessionId,action,prizeGrade,prizeId,awardPrizeCount):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/session/process"
        if prizeGrade==0:
            # 按照奖品发
            data = {"activityId":activityId,"sessionId":sessionId,"action":action,"prizeId":prizeId,"awardPrizeCount":awardPrizeCount}
        else:
            # 按照等级发
            data = {"activityId":activityId,"sessionId":sessionId,"action":action,"prizeGrade":prizeGrade,"awardPrizeCount":-1}
        # print(data )
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('获取所有的场次')
    def sessionlist(self, env, activityId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/session/list"
        data = {"activityId":activityId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('场次活动奖品信息')
    def sessionprize(self, env, activityId,sessionId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/session/prize/get"
        data = {"activityId":activityId,"sessionId":sessionId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('新增场次')
    # 参数 prossingStartTime 报名结束时间（抽奖开始时间）
    def saveSession(self, env, activityId,startTime,prossingStartTime,endTime):
        dayu_url = getconf(env, "dayu_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-manager/v1/activity/session/saveSession"
        data = {"activityId":activityId,"startTime":startTime,"prossingStartTime":prossingStartTime,"endTime":endTime}
        r=requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('删除场次')
    # 参数 prossingStartTime 报名结束时间（抽奖开始时间）
    def delSession(self, env, activityId,id):
        dayu_url = getconf(env, "dayu_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-manager/v1/activity/session/delSession"
        data = {"activityId":activityId,"id":id}
        r=requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('白名单分页查询')
    # 参数 prossingStartTime 报名结束时间（抽奖开始时间）
    def Whitelist(self, env, activityId):
        zhongtai_url = getconf(env, "zhongtai_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json","Token":token}
        url = zhongtai_url + "game-manager/v1/activity/participateWhitelist/list"
        data = {"activityId":activityId}
        r=requests.get(url,json=data,headers=headers,params={"activityId":activityId})
        return r

    @allure.step('白名单删除')
    # 参数 prossingStartTime 报名结束时间（抽奖开始时间）
    def delWhitelist(self, env, arr):
        zhongtai_url = getconf(env, "dayu_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json","Token":token}
        url = zhongtai_url + "game-manager/v1/activity/participateWhitelist/delete"
        data = {"ids":arr}
        # print (data)
        r=requests.post(url,headers=headers,json=data)
        return r

    @allure.step('批量报名参与最近的场次')
    # 参数 activityId
    def partcWhitelist(self,env,activityId):
        zhongtai_url = getconf(env,"dayu_url")
        token = buslogin(env)
        headers = {"Content-Type": "application/json","Token":token}
        url = zhongtai_url + "game-manager/v1/activity/participateWhitelist/exchangeWhite/"+str(activityId)
        print(url)
        # data = {"activityId":activityId}
        r = requests.post(url,headers=headers)
        return  r


class TestUser():
    @allure.step('用户参与活动')
    # 参数：
    # activityId	Integer	活动id
    # score	Integer	分数
    # qrCodeKey	string	二维码key
    # userId	string	会员id
    # openId	string	openId
    # phone	string	用户手机号
    # 返回参与id
    def joinparti(self,env,activityId,openIdorphone,score):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/join"
        # print (url)
        if score=='phone':
            data = {"activityId": activityId, "phone": openIdorphone}
        elif score=='noopenId':
            data = {"activityId": activityId}
        elif isinstance(score,str):
            data = {"activityId": activityId,"openId":openIdorphone,"qrCodeKey":score,"score":0}
        else:
            data = {"activityId":activityId,"openId":openIdorphone,"score":score}
        # print ("参与传参",data)
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('userid和openid参与活动')
    def memberjoinparti(self,env,activityId,openId,userId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/join"
        # print (url)
        data = {"activityId":activityId,"openId":openId,"userId":userId}
        # print ("参与传参",data)
        r=requests.post(url,json=data,headers=headers)
        return r

    # 新参与接口
    @allure.step('线下打卡参与')
    def newjoin(self,env,activityId,openId,appid,userId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/new/join"
        data = {"activityId":activityId,"appid":appid,"openId":openId,"userId":userId}
        print (data)
        r=requests.post(url,json=data,headers=headers)
        return r


    @allure.step('用户刷新分数')
    # 参数：id：参与id，activityId：活动id，openId：微信id，score：活动得分
    def updateScore(self,env,id,activityId,openId,score):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/updateScore"
        data = {"id":id,"activityId": activityId,"openId":openId,"score":score}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('用户最后提交分数')
    # 参数：id：参与id，activityId：活动id，openId：微信id，score：活动得分
    def commitScore(self,env,id,activityId,openId,score):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/commitScore"
        data = {"id":id,"activityId": activityId,"openId":openId,"score":score}
        r = requests.post(url,json=data,headers=headers)
        # print (r)
        return r

    @allure.step('检查用户能否参与')
    # 参数：activityId：活动id，openId：微信id
    def checkparti(self,env,activityId,openId,userId=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/check"
        data = {"activityId":activityId,"openId":openId,"userId":userId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('获取用户剩余次数')
    # 参数：activityId：活动id，openId：微信id
    def restTime(self,env,activityId,openId,userId=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/restTime/get"
        data = {"activityId":activityId,"openId":openId,"userId":userId}
        r=requests.post(url,json=data,headers=headers)
        return r


    @allure.step('用户活动参与记录')
    # 参数：activityId：活动id，openId：微信id
    def participation(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/list"
        data = {"activityId":activityId,"openId":openId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('增加用户参与次数')
    # 参数：activityId：活动id，openId：微信id,addTimesType:1:分享,3.消耗积分
    def addTimes(self,env,activityId,openId,addTimesType,userId=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/addTimes"
        data = {"activityId":activityId,"openId":openId,"addTimesType":addTimesType,"userId":userId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('根据参与信息抽奖')
    # 参数：activityId：活动id，playRecordId：参与id
    # 非必参数sessionId:场次id，winningStrategy：抽奖类型3抽概率奖，7抽场次奖
    def partilottery(self,env,activityId,playRecordId,winningStrategy):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/lottery"
        data = {"activityId": activityId, "playRecordId": playRecordId, "winningStrategy": winningStrategy}
        r=requests.post(url,json=data,headers=headers)
        return r


    @allure.step('抽得分兑换奖')
    def exchangeprize(self,env,activityId,openId,prizeId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/prize/exchange"
        data = {"activityId": activityId, "openId": openId, "prizeId": prizeId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('粉丝信息')
    # 参数：activityId：活动id，openId：openId
    def getwechatInfo(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/wechatInfo/get"
        print (url)
        data = {"activityId":activityId,"openId":openId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('场次活动参与(多摇用)')
    def sessionpart(self,env,activityId,openId,sessionId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/session/participate"
        data = {"activityId":activityId,"openId":openId,"sessionId":sessionId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('检查用户是否需要弹窗规则')
    # 参数：activityId：活动id，openId：openId
    def viewsRule(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/viewsRule/check"
        data = {"activityId":activityId,"openId":openId}
        r=requests.post(url,json=data,headers=headers)
        return r

    @allure.step('查询会员接口')
    # 参数：activityId：活动id，openId：openId
    def getmember(self,env,size,registerChannelTypeList):
        zhongtai_url = getconf(env, "zhongtai_url")
        token=buslogin(env)
        headers = {"Content-Type": "application/json","Token":token}
        url = zhongtai_url + "platform-member-server/v1/member/page"
        print(url)
        data = {"size":size,"current":1,"registerChannelTypeList": registerChannelTypeList}
        r = requests.post(url,json=data,headers=headers,params=data)
        return r

    #中台接口变动，已停用
    @allure.step('按照注册方式查会员')
    def getmemopenid(self,env, size, registerChannelTypeList):
        # 查商场下的会员
        xx = TestUser().getmember(env, size, registerChannelTypeList)
        openId = list()
        for i in range(size):
            openId.append(xx.json()['data']['records'][i]['openid'])
            # print (xx.json()['data']['records'][i]['cardCode'])
        return openId

    @allure.step('sql查询会员,返回openid')
    def getmemsql(self,env, branchid):
        # 查商场下的会员,限制了查询数量：10
        branchid=str(branchid)
        #sql='SELECT identifier FROM buorg.org_member_identifier WHERE branch_id ="' + branchid + '"and identifier_ns in (select app_id from buorg.wechat_branch_wechat WHERE  branch_id="' + branchid + '")and identifier in (SELECT open_id FROM  buorg.wechat_fans WHERE  branch_id="' + branchid + '") and deleted=0 limit 10'
        for i in range(64):
            sql = 'SELECT identifier FROM buorg.org_member_identifier_{} WHERE branch_id ="'.format(i) + branchid + '" AND identifier_type=1 and deleted=0 limit 10'
            openId =common.opmysql.OperationDb(env).select_all(sql)
            if len(openId) != 2:
                openIdlist = openId.split(',')
        openIdlists=[]
        for i in openIdlist:
            openIdlists.append(i[i.find(":")+1:i.find("}")])
        return openIdlists

    @allure.step('sql查询小程序会员，返回openid')
    def getminiappmemsql(self, env, branchid):
        # 查商场下的会员,限制了查询数量：10
        branchid = str(branchid)
        for i in range(64):
            sql = 'SELECT identifier FROM buorg.org_member_identifier_{} WHERE branch_id ='.format(i) + branchid + ' and identifier_type=2 and deleted=0 limit 10'
            openId =common.opmysql.OperationDb(env).select_all(sql)
            if len(openId) != 2:
                openIdlist = openId.split(',')
        openIdlists=[]
        for i in openIdlist:
            openIdlists.append(i[i.find(":")+1:i.find("}")])
        return openIdlists

    @allure.step('sql查询会员，返回手机号')
    def getmemphonesql(self,env, branchid):
        branchid=str(branchid)
        for i in range(64):
            sql ='SELECT identifier FROM buorg.org_member_identifier_{} WHERE branch_id="'.format(i) + branchid + '" AND identifier_ns="" AND deleted=0 ORDER BY gmt_create desc limit 10'
            phone =common.opmysql.OperationDb(env).select_all(sql)
            if len(phone) != 2:
                phonelist = phone.split(',')
        phonelists=[]
        for i in phonelist:
            phonelists.append(i[i.find(":")+1:i.find("}")])
        return phonelists

    @allure.step('获取会员信息')
    # 参数：activityId：活动id，openId：openId
    def getmemberInfo(self,env, activityId, openId,isShowPoint):
        member_url = getconf(env, "member_url")
        headers = {"Content-Type": "application/json"}
        url = member_url + "v1/user/memberInfo/get"
        data = {"activityId": activityId, "openId": openId,"isShowPoint":isShowPoint}
        # print (data)
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('获取参与id')
    def getId(self,env, activityId, qrCodeKey):
        member_url = getconf(env, "member_url")
        headers = {"Content-Type": "application/json"}
        url = member_url + "v1/user/participation/getId"
        data = {"activityId": activityId, "qrCodeKey": qrCodeKey}
        r = requests.post(url,json=data,headers=headers)
        return r

    # ryware已停用
    @allure.step('通过openid和appid查询会员信息')
    # 参数：activityId：活动id，openId：openId
    def getOneInfoByOpenidAndAppid(self,env, openId,appId,branchId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "platform-ryware-server/v1/ryware/member/getOneInfoByOpenidAndAppid"
        # print (url)
        data = {"openId": openId,"appId":appId,"branchId":branchId}
        # print ("通过openid和appid查询会员信息",data)
        r = requests.get(url,headers=headers,params=data)
        return r

    # ryware已停用
    @allure.step('通过openid查询会员信息')
    # 参数：activityId：活动id，openId：openId
    def getOneInfoByOpenid(self,env, openId,branchId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "platform-ryware-server/v1/ryware/member/getOneInfoByCurrentOfficeAccountOpenid"
        # print (url)
        data = {"openId": openId,"branchId":branchId}
        # print ("通过openid查询会员信息",data)
        r = requests.get(url,headers=headers,params=data)
        return r

    @allure.step('通过openid和branchid查询会员信息')
    #参数：openid，branchId，identifierType:OFFICIAL_ACCOUNTS公众号 MINI_APPS 小程序
    #小程序会员因中台bug，暂不支持
    def getInfoByOpenIdAndBranchId(self,env,openid,branchId,identifierType):
        dayu_url = getconf(env,"dayu_url")
        #headers = {"Content-Type": "application/json"}
        url = dayu_url + "openapi-service/openapi/v1/member/getInfoByOpenIdAndBranchId?" + "openid="+str(openid) + "&branchId="+str(branchId) + "&identifierType="+str(identifierType)
        #print(url)
        token = buslogin(env)
        r = requests.get(url,params={"Token":token})
        return r

    @allure.step('用户参与加抽奖')
    # 参数：activityId：活动id
    # score,qrCodeKey,userId,openId,phone
    #userId，openId，phone 三个必须传一个
    def joinlottery(self,env, activityId,openId,userId = ""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/lottery/join"
        data = {"activityId": activityId,"openId":openId,"userId":userId}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('用户活动抽奖记录')
    # 参数：activityId：活动id
    # score,qrCodeKey,userId,openId,phone
    #userId，openId，phone 三个必须传一个
    def joinlotteryList(self,env, activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/lottery/list"
        data = {"activityId": activityId,"openId":openId,"pageSize":10000000}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('用户报名')
    # 参数：userId,phone,openId，三个传一个
    # exchangeType：兑换类型： 1：”分享” 2：”关注” 3：”消耗积分” 4：”新会员” 5：”白名单”
    # count,报名的兑换次数，exchangeType=3时必传
    # stubId，票根id，exchangeType=5时必传
    def signUp(self,env, activityId,sessionId,phoneopenid,realphoneopenid,exchangeType,count,stubIdorinvite,i):
        dayu_url = getconf(env, "dayu_url")
        appid=getconf(env, "appid")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/signUp"
        zhufuyu=["每逢佳节胖三斤","五一过后胖若两人","一夜暴富我们共同的梦","天天开心，释放活力","清除压力，好运给力","工作到点，休息多一点","劳动人民最光荣！","春来同盼 清平山川","愿风调雨顺江山安，好将新茶烹与旧年欢","虽未量岁功，即事多所欣","好花常有，好梦长留","愿你灯火阑珊处，仍存红泥小火炉","做喜欢的事，牵住爱的人。","无论清晨还是傍晚 这座城市总有一盏星光是属于你的","珍惜所有的不期而遇，看淡所有的不辞而别。","哪怕岁月荏苒，愿你一如年少模样 永远心怀善意","平安喜乐，得偿所愿。","所有快乐，无需假装，此生尽兴，赤诚善良","快乐太难，还是腰缠万贯","劳动节快乐！","把工作的劳累卸下,让快乐的心情挥发","劳动者最快乐，劳动最光荣","辛勤劳动生活美，脚踏实地心里甜，汗水浇灌幸福花，灿烂花香飘四方","平日里忙碌辛苦的你，尽情休息玩乐，放松自己，为下一个征程整装待发！","辛勤的劳动，换来丰收的果实","五一假期真是好，五天小假乐逍遥","五一假日到，五天不嫌少。工作脑后抛，快乐身边绕。","钱多钱少，常有就好","工作顺心如意，事业蒸蒸日上","前途阳光照耀，身体健康无恙"]
        # 判断，用来区分后台导入和前端录入
        if i==1:#前端錄入，不要手機號的其他關鍵字
            data={"activityId": activityId,"sessionId":sessionId,"exchangeType":exchangeType,"count":count,"stubId":stubIdorinvite}
        if i==0:#前端錄入小票報名，要手機號
            data={"activityId": activityId,"sessionId":sessionId,phoneopenid:realphoneopenid,"exchangeType":exchangeType,"count":count,"stubId":stubIdorinvite}
        if i==2:#公众号会员，只要openid
            data={"activityId": activityId,"sessionId":sessionId,"exchangeType":exchangeType,"count":count,phoneopenid:realphoneopenid}
        if i==3:#小程序会员，openid+appid
            data={"activityId": activityId,"sessionId":sessionId,"appid":appid,"exchangeType":exchangeType,"count":count,phoneopenid:realphoneopenid}
        r = requests.post(url,json=data,headers=headers)
        print(data)
        return r

    @allure.step('H5授权验证登录接口')
    # 增加积分的分数：changePoint,会员编号：cardCode
    def authLogin(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/common/authLogin"
        token = buslogin(env)
        data = {"activityId":activityId,"openId":openId}
        r = requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('用户增加积分')
    #ryware已停用
    # 增加积分的分数：changePoint,会员编号：cardCode
    def increasepoint(self,env,changePoint,cardCode):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "platform-ryware-server/v1/ryware/point/increase"
        token = buslogin(env)
        data = {"pointSource": 1,"pointChannelCode": "cloudwalk","changePoint":changePoint,"cardCode":cardCode}
        r = requests.post(url,json=data,headers=headers,params={"Token":token})
        # print (r.url)
        return r

    @allure.step('会员积分查询')
    #会员编号：cardCode
    def queryTotalPoint(self,env,cardCode):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        #url = dayu_url + "platform-ryware-server/v1/ryware/point/queryTotalPoint"
        url = dayu_url + "openapi-service/openapi/v1/point/getTotalPoint"
        token = buslogin(env)
        data = {"cardCode":cardCode,"Token":token}
        r = requests.get(url,headers=headers,params=data)
        return r

    @allure.step('用户增加积分new')
    #增加积分-inmall后更新版本-20201208-wuchunjiao
    def addPoint(self,env,changePoint,cardCode):
        dayu_url = getconf(env,"dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "platform-point-server/v1/point/changePoint"
        token = buslogin(env)
        data = {"cardCode":cardCode, "changePoint":changePoint, "pointSource": 4,"tranType": 1}
        r = requests.post(url,json=data,headers=headers,params={"Token":token})
        return r

    @allure.step('获取会员信息-game')
    def getMemInfo(self,env,appid,activityId,openId,isShowPoint):
        dayu_url = getconf(env,"dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/memberInfo/get"
        data = {"appid":appid,"activityId":activityId,"openId":openId,"isShowPoint":isShowPoint}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('天玑2.0答题游戏获取题目')
    def getActicity_questions(self,env,activityId,openId,userId=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/questions"
        data = {"activityId": activityId,"openId":openId,"userId":userId}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('天玑2.0答题游戏提交题目')
    def commitQuestions(self,env,activityId,openId,userId,playerId,answerCodes):
        print(playerId)
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/questions/commit"
        data = {"activityId": activityId,"openId":openId,"userId":userId,"playRecordId":playerId,"answerCodes":answerCodes}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('天玑2.0抽概率奖')
    def joinlottery_new(self,env,activityId,openId,winningStrategy):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/lottery/join"
        data = {"activityId": activityId,"openId":openId,"winningStrategy":winningStrategy}
        r = requests.post(url,json=data,headers=headers)
        return r

    @allure.step('根据得分抽奖')
    def topScoreLotty(self,env,playRecordId,activityId,score):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v2/lotty/topScoreLotty"
        data = {"activityId": activityId, "playRecordId": playRecordId, "score": score}
        r=requests.post(url,json=data,headers=headers)
        print(r.json())
        return r

    #集赞接口
    @allure.step("集赞参与")
    def jizan_join(self,env,activityId,openId,userId="",phone=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/user/participation/new/join2"
        data = {"activityId": activityId, "userId": userId, "openId": openId,"phone":phone}
        r=requests.post(url,json=data,headers=headers)
        print("集赞参与",r.json())
        return r

    @allure.step("集赞助力")
    def jizan_help(self,env,activityId,openId,byOpenId,userId="",byUserId="",phone="",byPhone=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/collect/save"
        data = {"activityId": activityId, "userId": userId, "openId": openId,"phone":phone,"byOpenId":byOpenId,"byUserId":byUserId,"byPhone":byPhone}
        r=requests.post(url,json=data,headers=headers)
        print("集赞助力:",r.json())
        return r

    @allure.step("集赞助力列表")
    def jizan_assitList(self,env,activityId,openId,playRecordId="",userId="",phone=""):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/collect/list"
        data = {"activityId": activityId, "userId": userId, "openId": openId,"phone":phone,"playRecordId":playRecordId}
        r=requests.post(url,json=data,headers=headers)
        print("集赞助力列表:",r.json())
        return r

    @allure.step("集赞收取助力值")
    def jizan_collect(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/collect/addScore"
        data = {"activityId": activityId, "openId": openId}
        r=requests.post(url,json=data,headers=headers)
        #print("集赞收取助力值：",r.json())
        return r

    @allure.step("集赞兑换奖品")
    def jizan_exchangePrize(self,env,activityId,openId):
        dayu_url = getconf(env, "dayu_url")
        headers = {"Content-Type": "application/json"}
        url = dayu_url + "game-portal/v1/activity/collect/exchange"
        data = {"activityId": activityId, "openId": openId}
        r=requests.post(url,json=data,headers=headers)
        print("集赞兑换奖品：",r.json())
        return r.json()

    #云逛店发送内容消息
    def login(self,env):
        headers = {"Content-Type": "application/json;charset=UTF-8"}
        url = "http://dayuv4.rongyi.com/cloudwalk-portal/v1/send/broadcast"
        data = {"message": "test","playerId":22,"cloudwalkId":1}
        r = requests.post(url,json=data,headers=headers)
        return r

    #大禹token
    def get_token(self):
        headers = {"Content-Type": "application/json;charset=UTF-8"}
        url = "http://fe1.rongyi.com:8186/buorg/v1/session/login"
        data = {"account":"hdyxcs","password":"Hdyxcs2022@","clientId":1,"accountType":"BRANCH_ADMIN"}
        r = requests.post(url,json=data,headers=headers)
        return r.json()["token"]

#大禹登录
    # def test_sessionlogin(self,env):
    #     zhongtai_url = getconf(env, "zhongtai_url")
    #     token = buslogin(env)
    #     headers = {"Content-Type": "application/json;charset=UTF-8","Token":token,"application": "cms"}
    #     url = zhongtai_url + "buorg/v1/session/login"
    #     data = {"account": "csyyzx02","password":"a12345678","clientId":1}
    #     r = requests.post(url,json=data,headers=headers)
    #     return r

if __name__ == '__main__':
    a=TestActivity()
    b=TestUser()
    c=TestSession()